<?php
/**
 * Created by IntelliJ IDEA.
 * User: m1573
 * Date: 2022/7/20
 * Time: 22:15
 */
include("include/util.inc.php");
$username = $_GET["username"];
$password = $_GET["password"];

$sql = "SELECT count(*) from users where username=?";
$sth = $PDO ->prepare($sql);
$sth->bindParam(1,$username);
$sth->execute();
$res = $sth->fetch();
if(strcmp($res["count(*)"],"0")!=0){
    echo "the name is registed";
}else{
    $hash_pass = password_hash($password,PASSWORD_DEFAULT);


//echo password_verify("1111aaaa",$hash_pass);

    $sql = "INSERT INTO
                  users(username,password)
                  VALUE(?,?)";
    $sth = $PDO ->prepare($sql);
    $sth->bindParam(1,$username);
    $sth->bindParam(2,$hash_pass);
    $sth->execute();
    echo "regist succ";
}



?>
